<template>
<view class="xmzs">
	<view class="left">
		<view class="title">
			重点督导项目
		</view>
		<view class="chart_container">
			<qiun-data-charts
				type="column" 
				:chartData="chartData"
				:opts="opts"
				:canvas2d="true"
				canvasId="xmzs_charts"
				@getIndex="chartClick"/>
		</view>
	</view>
	<view class="right">
		<view class="right_top">
			<view class="right_top_title">
				在建 {{numberList.zjcount}}
			</view>
			<view class="right_top_content">
				<view class="right_top_content_item" 
					v-for="(item,index) in numberList.zaijianLevel" 
					:key="index"
					v-if="'省级市级区级'.indexOf(item.prolevel)!=-1"
					:style="{
						backgroundColor: color[index%color.length],
					}"
					@click="goToPage(item.prolevel)">
					{{item.count + ' - '}}{{item.prolevel}}
				</view>
			</view>
		</view>
		<view 
			class="right_bottom"
			@click="goToPage">
			<view class="right_bottom_left">
				<view class="">{{numberList.count}}</view>
				<view class="" style="font-size: 14px;">项目总数</view>
			</view>
			<view class="right_bottom_right">
				<view class="">已完工 {{numberList.wgcount}}</view>
				<view class="">已超时 {{numberList.cscount}}</view>
			</view>
		</view>
	</view>
</view>
</template>

<script>
	import{
		doubleClick,
	} from "@/common/OtherTools";
	export default { //各级项目总数组件
		name: "Xmzs",
		data() {
			return {
				numberList: [],
				cWidth: '',
				cHeight: '',
				color:['#2FC25B','#1890FF','#FACC14','#ffaaff'],
				resData:{},
				chartData:{},
				opts:{
					"type": "column",
					"canvasId": "",
					"canvas2d": true,
					"background": "none",
					"animation": true,
					"timing": "easeOut",
					"duration": 1000,
					"color": [
						"#1890FF",
						"#91CB74",
						"#FAC858",
						"#EE6666",
						"#73C0DE",
						"#3CA272",
						"#FC8452",
						"#9A60B4",
						"#ea7ccc"
					],
					"padding": [
						15,
						15,
						15,
						15
					],
					"rotate": false,
					"errorReload": true,
					"fontSize": 10,
					"fontColor": "#666666",
					"enableScroll": true,
					"touchMoveLimit": 60,
					"enableMarkLine": false,
					"dataLabel": true,
					"dataPointShape": true,
					"dataPointShapeType": "solid",
					"xAxis": {
						"disabled": false,
						"axisLine": false,
						"axisLineColor": "#CCCCCC",
						"calibration": false,
						"fontColor": "#666666",
						"fontSize": 10,
						"rotateLabel": false,
						"itemCount": 4,
						"boundaryGap": "center",
						"disableGrid": true,
						"gridColor": "#CCCCCC",
						"gridType": "solid",
						"dashLength": 4,
						"gridEval": 1,
						"scrollShow": false,
						"scrollAlign": "left",
						"scrollColor": "#A6A6A6",
						"scrollBackgroundColor": "#EFEBEF",
						"format": "",
					},
					"yAxis": {
						"disabled": true,
						"disableGrid": true,
						"splitNumber": 5,
						"gridType": "solid",
						"dashLength": 8,
						"gridColor": "#CCCCCC",
						"padding": 10,
						"showTitle": false,
						"data": []
					},
					"legend": {
						"show": false,
						"position": "bottom",
						"float": "center",
						"padding": 5,
						"margin": 5,
						"backgroundColor": "rgba(0,0,0,0)",
						"borderColor": "rgba(0,0,0,0)",
						"borderWidth": 0,
						"fontSize": 13,
						"fontColor": "#666666",
						"lineHeight": 11,
						"hiddenColor": "#CECECE",
						"itemGap": 10
					},
					"extra": {
						"column": {
							"type": "stack",
							"width": 18,
							"seriesGap": 2,
							"categoryGap": 3,
							"barBorderCircle": false,
							"linearType": "none",
							"linearOpacity": 1,
							"colorStop": 0,
							"meterBorder": 1,
							"meterFillColor": "#FFFFFF",
							"activeBgColor": "#000000",
							"activeBgOpacity": 0.08,
							"meterBorde": 1
						},
						"tooltip": {
							"showBox": true,
							"showArrow": true,
							"showCategory": true,
							"borderWidth": 0,
							"borderRadius": 0,
							"borderColor": "#000000",
							"borderOpacity": 0.7,
							"bgColor": "#000000",
							"bgOpacity": 0.7,
							"gridType": "solid",
							"dashLength": 4,
							"gridColor": "#CCCCCC",
							"fontColor": "#FFFFFF",
							"splitLine": true,
							"horizentalLine": false,
							"xAxisLabel": false,
							"yAxisLabel": false,
							"labelBgColor": "#FFFFFF",
							"labelBgOpacity": 0.7,
							"labelFontColor": "#666666"
						},
						"markLine": {
							"type": "solid",
							"dashLength": 4,
							"data": []
						}
					}
				},
			};
		},
		mounted() {
			this.getData();
		},
		methods: {
			chartClick:doubleClick(function(param){
				param = this.resData.level[param.currentIndex.index].prolevel;
				this.goToPage(param);
			}),
			goToPage(param){  //跳转到指定页面,携带参数(在建的级别)
				uni.navigateTo({
				    url: `/pages/project_gk/project_gk?level=${param}`,
				});
			},
			getData(){
				this.$ajax({
					url: '/wx/index/count',
					method: 'GET',
					success: res => {
						this.numberList = res.data.data;
					}
				});
				this.$ajax({
					url: '/sys/web/statusAndLevel',
					method: 'POST',
					success: res => {
						let level = res.data.data.level; 
						this.resData = res.data.data;
						this.showRing(level);
					}
				})
			},
			showRing(chart_data) {  //draw图表
				this.chartData = {
					categories: chart_data.map(item=>{
						return item.prolevel;
					}),
					series:[
						{
							"name": "项目数量",
							"data":chart_data.map(item=>{
								return item.count;
							}),
							"color": '#1890FF',
							'format':(item) =>{
								if(item == 0){
									return ''
								}else{
									return item
								}
							}
						},
					],
				};
			},
		},
	}
</script>

<style lang="scss" scoped>
	@mixin flex_layout_row {
		//水平布局
		display: flex;
		flex-direction: row;
	}

	@mixin flex_layout_column {
		//垂直布局
		display: flex;
		flex-direction: column;
	}
	.xmzs {
		width: 100%;
		background-color: #ffffff;
		border-radius: 5px;
		height: fit-content;
		@include flex_layout_row;
		align-items: stretch;
		box-sizing: border-box;
		overflow: hidden;
		.left {
			flex: 1.5;
			width: 0;
			border-radius: 5px;
			margin-right: 10px;
			.title{
				font-size: 12px;
				font-weight: bold;
				color: #555555;
				text-align: center;
				line-height: 2;
			}
			.chart_container {
				width: 100%;
				height:150px;
				background-color: #FFFFFF;
			}
		}

		.right {
			flex: 1;
			width: 0;
			padding: 10px;
			box-sizing: border-box;

			.right_top {
				border-radius: 5px;
				background-color: rgba(237, 240, 245, .7);
				color: #4f4f4f;
				padding: 5px;

				.right_top_title {
					font-size: 15px;
					// font-weight: bold;
				}

				.right_top_content {
					display: flex;
					flex-direction: column;
					text-align: center;
					margin-top: 5px;
					font-size: 12px;
					border-radius: 3px;
					overflow: hidden;
				}
			}

			.right_bottom {
				@include flex_layout_row;
				margin-top: 10px;
				justify-content: space-between;
				align-items: center;
				color: #505155;

				.right_bottom_left {
					text-align: center;
					font-size: 20px;
					// font-weight: bold;
				}

				.right_bottom_right {
					font-size: 13px;

					// font-weight: bold;
					>view {
						margin: 5px 0;
					}
				}
			}
		}
	}
</style>
